<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      ul {
        list-style: none;
        padding: 0;
        margin: 0;
      }
      ul li {
        border: solid;
        margin: 5px;
      }
    </style>
  </head>
  <body>
    <ul>
      <li>list1 <button onclick="del(this)">X</button></li>
      <li>list2 <button onclick="del(this)">X</button></li>
      <li>list3 <button onclick="del(this)">X</button></li>
      <li>list4 <button onclick="del(this)">X</button></li>
    </ul>
    <script>
      function del(obj) {
        obj.parentElement.remove();
      }
    </script>
  </body>
</html>
